package com.detoandy.service;

import com.detoandy.dao.UserRepository;
import com.detoandy.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhengdt on 2017/8/20.
 */
@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    public User getUserById(String id) {
        return userRepository.findOne(id);
    }

    public void updateUser(User user) {
        userRepository.updateUser(user.getName(),user.getPassword(),user.getPassword());
        //return
    }

    public List<User> findByExample(User user) {
        Example<User> userExample = Example.of(user);
        return userRepository.findAll(userExample);
    }

    public List<User> getAllUser() {
        return userRepository.findAll();
    }

}
